#!/bin/bash

for i in `kubectl top node|grep unknown|awk '{print $1}'`
do
  podname=`kubectl get pod -n monitoring -owide|grep node-exporter|grep $i|awk '{print $1}'`
  if [[ `kubectl get node|grep $i|awk '{print $2}'` == "Ready" || $i == "sgscc-uvl-app100.ych.com" ]];then
    echo "delete pod $podname"
    kubectl delete pod $podname -n monitoring
  fi
done
